package cn.ly.jmockittest;

import cn.ly.easymocktest.User;
import mockit.Injectable;

/**
 * Created by liuyu21 on 2017/10/22.
 */
public class Service {
    private Dao dao;
    private LoginDao loginDao;

    /**
     * 根据存货量判断货物是否畅销
     *
     * @param group
     * @return
     */
    public Status checkStatus(String group,Long id) {
        User user = dao.getUser(id);
        if(!loginDao.login(user)){
            return null;
        }
        int count = this.dao.getStoreCount(group);
        if (count <= 0) {
            return Status.UNKOWN;
        } else if (count <= 800) {
            return Status.UNSALABLE;
        } else if (count <= 1000) {
            return Status.NORMAL;
        } else {
            return Status.SELLINGWELL;
        }
    }
}
